package manager;

import java.util.ArrayList;
import data.dao.*;
import data.dto.*;
import data.searchdto.*;
import data.dao.daoFactory.*;

public class UserManager {
	private UserDAO userDAO;
	private ArrayList<UserDTO> userList;

	public UserManager() {
		this.userDAO = UserFactory.loadInstance().getUserDAO();
	}

	public UserDTO findUser(userSearchDTO usersearchdto) throws UserDAOException {
		UserDTO user = new UserDTO();
		try {
			user = userDAO.findUser(usersearchdto);
		} catch (UserDAOException e) {
			e.printStackTrace();
		}
		return user;
	}

	public ArrayList<UserDTO> findAllUser() throws UserDAOException {
		userList = new ArrayList<UserDTO>();
		try {
			userList = userDAO.findAllUser();
		} catch (UserDAOException e) {
			e.printStackTrace();
		}
		return userList;
	}

	public void insertLeaveDetail(UserDTO User) throws UserDAOException {
		try {
			userDAO.insertLeaveDetail(User);
		} catch (UserDAOException e) {
			e.printStackTrace();
		}

	}

	public void updateLeaveDetail(UserDTO User) throws UserDAOException {
		try {
			userDAO.updateLeaveDetail(User);
		} catch (UserDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteLeaveDetail(UserDTO User) throws UserDAOException {
		try {
			userDAO.deleteLeaveDetail(User);
		} catch (UserDAOException e) {
			e.printStackTrace();
		}

	}
}
